public class Text_2 {
    static class Solution {
        public int removeElement(int[] nums, int val) {
            //将不等于的赋值过去
            int length = nums.length;
            int[] array = new int[length];
            int i = 0;
            int count= 0;

            for(int num :nums){
                if(num!=val){
                    array[i] = num;
                    i++;
                    count++;
                }
            }

            for(i = 0;i<length;i++){
                nums[i] = array[i];
            }

            return count;
        }
    }


    static class Solution1 {
        public int removeElement(int[] nums, int val) {
            //拷贝复制
            int count = 0;


            for(int num:nums){
                if(num!=val){
                    nums[count] = num;
                    count++;
                }
            }
            return count;
        }
    }



}
